|
![](/i/fill.gif) |
In article <399feed3@news.povray.org>, "Thorsten Froehlich"
<tho### [at] trf de> wrote:
> This still doesn't answer my question: Why?
> Why would more OO features in the scene language improve its usability?
I've often wished I could store a bunch of different types of data for a
data structure in one chunk. Objects are an obvious place to put them. I
had to settle for a bunch of global arrays, and eventually gave up.
The technique of #declaring a bunch of variables and #indluding a file
is clumsy and can lead to variable name conflicts. Macros don't have
variable numbers of parameters, so you sometimes have to resort to the
same thing: #declaring variables before calling the macro. Long lists of
macro parameters are difficult to keep track of. If object-oriented
features were added, you could simply declare an object that does
whatever was done by #including or calling a macro. For example, a lens
flare object could be used like this:
#declare MyFlare = object {PlainLensFlare};
MyFlare.SetSize(5);
MyFlare.SetPos(< 5, 1, 6>);
MyFlare.SetColor(< 1, 0, 0.5>);
object {MyFlare.CalculateFlare();}
#declare MyFlare = object {SparkleLensFlare};
MyFlare.SetSize(2);
MyFlare.SetPos(<-5, 1, 6>);
MyFlare.SetColor(< 0, 1, 0>);
object {MyFlare.CalculateFlare();}
MyFlare.SetPos(< 0, 5, 6>);
MyFlare.SetColor(< 1, 1, 0>);
object {MyFlare.CalculateFlare();}
This would make 3 lens flares, a purple one to the right, a smaller
green one to the left, and a yellow one above. You would only need to
specify the parameters which you want to change, you could have as many
as you want with no trouble, and you would have far fewer problems with
variable name collision, since you would only need to watch out for the
object names, not the parameters. If you wanted to make a slightly
different lens flare, you wouldn't have to copy/paste a bunch of code
from the original include and modify it, you could just make an object
from one of the original objects and override some of the member macros.
> Would it be easier to learn?
No, but since the existing language wouldn't need to be disturbed, you
wouldn't have to learn it. It would be considerably easier to learn than
C++, though.
> Would it be fast to parse?
It probably wouldn't be noticeably slower without benchmarking, and
could possibly allow doing some things in a way that would parse faster
than previously possible.
> Would it allow porting C/C++/Java programs to POV-script?
No more than you can already port C or Pascal programs to POV-Script.
Why would you want to do such a thing, anyway?
> In short : What are the _practical_ benefits for the scene
> description, the primary purpose of the POV scene description
> language?
--
Christopher James Huff
Personal: chr### [at] mac com, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tag povray org, http://tag.povray.org/
<><
Post a reply to this message
|
![](/i/fill.gif) |